package com.air.designmodel.nine;

/**
 * 遥控器
 *
 * @author shent
 */
public class RemoteControl {
    Command[] onCommands;
    Command[] offCommands;
    Command[] otherCommands;

    public RemoteControl() {
        onCommands = new Command[7];
        offCommands = new Command[7];
        otherCommands = new Command[7];

        Command noCommand = new NoCommand();
        for (int i = 0; i < 7; i++) {
            onCommands[i] = noCommand;
            offCommands[i] = noCommand;
            otherCommands[i] = noCommand;
        }
    }


    public void setCommand(int slot, Command onCommand, Command offCommand) {
        onCommands[slot] = onCommand;
        offCommands[slot] = offCommand;
    }

    public void setCommand(int slot, Command otherCommand) {
        otherCommands[slot] = otherCommand;
    }

    public void onButtonWasPressed(int slot) {
        onCommands[slot].execute();
    }

    public void offButtonWasPressed(int slot) {
        offCommands[slot].execute();
    }

    public void otherButtonWasPressed(int slot) {
        otherCommands[slot].execute();
    }
}
